Given an unlocked handle to a block of text, you need to apply a sequence of actions to the data. Internally, you must keep a current position pointer,
which starts at zero (ie, before the first character in the handle). The internal position pointer is constrained between 0 and GetHandleSize(data) at all times,
and if it becomes less than zero (respectively greater than GetHandleSize), then you must reset it to zero (respectively GetHandleSize).
The handle size will never exceed 1 Meg, and you will have plenty of memory to play with. Characters from chr(127)-chr(255) will never appear in the handle
or any strings. In response to each of the actions you need to apply the following action:
kActionMove - move the internal position forward by the amount field (which may be negative). (Example, kActionMove with amount set to kMaxHandleSize will set the internal pointer to be GetHandleSize( data )).
kActionInsert - Insert the replace string at the current location. (Example, if the internal pointer is GetHandleSize( data ), then the replace string will be appended to the handle.
kActionDelete - Delete the number of characters specified by the amount field. The internal pointer is never moved. If the amount field is greater than the number of characters after the internal pointer, then fewer characters are deleted such that the handle is truncated at the internal pointer.
kActionSearch - search forward (backwards if the kFlagBackwardsBit is set in the flags field) for the search field (case sensitively if the kFlagCaseSenstitiveBit is set in the flags field). The position pointer should be set to point before the first character of the string if it is found, or at GetHandleSize (zero if backwards) if not found. If there is a match at the initial position, it is not counted (ie, kActionMove -kMaxHandleSize, kSearch 'hello', kSearch 'hello' finds the second occurance of 'hello').
kActionSearchAndReplace - as for search, but when a match is found, replace it with the replace string. If the kFlagGlobalBit is set in the flags field, continue search until a match is not found but never search any characters of the replace string. (that is, if you replace 'aaa' with 'ABA' (case insensitively) in 'aaaaaaaa' you will get 'ABAABAaa', not 'ABABABAa')